load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "singleflight",
    srcs = ["singleflight.go"],
    importpath = "github.com/cockroachdb/cockroach/pkg/util/syncutil/singleflight",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/util/log",
        "//pkg/util/stop",
        "//pkg/util/syncutil",
        "//pkg/util/tracing",
        "//pkg/util/tracing/tracingpb",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_logtags//:logtags",
        "@io_opentelemetry_go_otel//attribute",
    ],
)

go_test(
    name = "singleflight_test",
    size = "small",
    srcs = ["singleflight_test.go"],
    embed = [":singleflight"],
    deps = [
        "//pkg/testutils",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/tracing",
        "//pkg/util/tracing/tracingpb",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_stretchr_testify//require",
    ],
)
